package com.team.employment.web.admin.controller.position;

import com.team.employment.common.result.Result;
import com.team.employment.model.entity.PositionInfo;
import com.team.employment.model.entity.PositionLevel2;
import com.team.employment.web.admin.service.PositionLevel2Service;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "二级职位层级管理")
@RestController
@RequestMapping("/admin/positionSecond")
public class positionLevel2Controller {

    @Autowired
    private PositionLevel2Service positionLevel2Service;

    @Operation(summary = "根据一级职位id查询二级职位列表")
    @GetMapping("getPositionLevel2/{positionInfoId}")
    public Result<List<PositionLevel2>> getPositionLevel2(@PathVariable("positionInfoId") Integer positionInfoId){
        List<PositionLevel2> positionLevel2List = positionLevel2Service.getPositionLevel2(positionInfoId);
        return Result.ok(positionLevel2List);
    }


    @Operation(summary = "保存或更新二级职位信息")
    @PostMapping("saveOrUpdate")
    public Result saveOrUpdate(@RequestBody PositionLevel2 positionLevel2) {
        positionLevel2Service.saveOrUpdate(positionLevel2);
        return Result.ok();
    }

    @Operation(summary = "级联逻辑删除二级职位")
    @DeleteMapping("/level2/{id}")
    public Result<Void> deleteLevel2(@PathVariable Long id) {
        //deleteCheck.DeleteCheckSuccessful(positionLevel2Service,id);
        positionLevel2Service.deleteLevel2(id);
        return Result.ok();
    }


}
